package Thread.Thread05;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class ThreadTest4 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        //使用Executors创建一个线程池
        ExecutorService pool = Executors.newFixedThreadPool(3);
        // 核心线程数量配置多少：
        //计算密集型： 核心线程数量 = cpu的核数 + 1
        // IO密集的任务： 核心线程数量 = cpu核数*2;

        Future submit1 = pool.submit(new MyCallble(100));
        Future submit2 = pool.submit(new MyCallble(200));
        Future submit3 = pool.submit(new MyCallble(300));
        Future submit4 = pool.submit(new MyCallble(400));
        System.out.println(submit1.get());
        System.out.println(submit2.get());
        System.out.println(submit3.get());
        System.out.println(submit4.get());
//        Thread.State
    }
}
